
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 04/02/2013 22:01:29
-- Generated from EDMX file: E:\My\超级应用\trunk\SuperSolution\SuperLottery.Datas\DbModels\SuperLottery.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [MeiRiCai];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[LatestLotteryDraw]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LatestLotteryDraw];
GO
IF OBJECT_ID(N'[dbo].[LotteryDraw]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LotteryDraw];
GO
IF OBJECT_ID(N'[dbo].[WinningDetail]', 'U') IS NOT NULL
    DROP TABLE [dbo].[WinningDetail];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'LotteryDraw'
CREATE TABLE [dbo].[LotteryDraw] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [DrawDate] datetime  NOT NULL,
    [Issuer] nvarchar(max)  NOT NULL,
    [Game] nvarchar(max)  NOT NULL,
    [Issue] nvarchar(max)  NOT NULL,
    [Numbers] nvarchar(max)  NOT NULL,
    [BonusNumbers] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'WinningDetail'
CREATE TABLE [dbo].[WinningDetail] (
    [DrawId] bigint IDENTITY(1,1) NOT NULL,
    [Serial] tinyint  NOT NULL,
    [Award] nvarchar(max)  NOT NULL,
    [NumberOfWinners] int  NOT NULL,
    [MoneyPerWinner] int  NOT NULL
);
GO

-- Creating table 'LatestLotteryDraw'
CREATE TABLE [dbo].[LatestLotteryDraw] (
    [Id] bigint  NOT NULL,
    [DrawDate] datetime  NOT NULL,
    [Issuer] nvarchar(max)  NOT NULL,
    [Game] nvarchar(max)  NOT NULL,
    [Issue] nvarchar(max)  NOT NULL,
    [Numbers] nvarchar(max)  NOT NULL,
    [BonusNumbers] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'LotteryDraw'
ALTER TABLE [dbo].[LotteryDraw]
ADD CONSTRAINT [PK_LotteryDraw]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [DrawId] in table 'WinningDetail'
ALTER TABLE [dbo].[WinningDetail]
ADD CONSTRAINT [PK_WinningDetail]
    PRIMARY KEY CLUSTERED ([DrawId] ASC);
GO

-- Creating primary key on [Id] in table 'LatestLotteryDraw'
ALTER TABLE [dbo].[LatestLotteryDraw]
ADD CONSTRAINT [PK_LatestLotteryDraw]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------